package com.qiantu.phone.widget.btnview;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

import com.qiantu.phone.R;
import com.qiantu.phone.app.AppApplication;

/**
 * 画虚线
 * Created by luzx on 2019/05/05.
 */
public class FiveButtonView extends BaseBtnView {

    private static final int[] SELECTED_STATE_SET = {
            android.R.attr.state_selected
    };
    private static final int[] UNSELECTED_STATE_SET = {
            -android.R.attr.state_selected
    };
    private int strokeColor;
    private int strokeWidth;
    private Paint paint;
    private int textSize;
    private String centerText;
    private ColorStateList textColor;
    private Drawable drawable;
    private TextPaint mTextPaint;
    private int shadowRadius1;
    private int shadowRadius2;
    private int shadowRadius3;
    private int shadowRadiusDy1;
    private int shadowRadiusDy2;
    private int shadowRadiusDy3;
    private int lineColor;
    private int lineHeight;
    //    private RectF mLineRectF1;
//    private RectF mLineRectF2;
//    private RectF mLineRectF3;
//    private RectF mLineRectF4;
    private int addWidth;
    private float centerRadius;
    private float bigStrokeWidth;
    private Path mPath1;
    private Path mPath2;
    private Path mPath3;
    private Path mPath4;
    private Path mPath5;
    private double c;
    private double bigC;
    private RectF mRingOutRectF;
    private RectF mRingInRectF;
    private float outLineRectFHalfAngle;
    private float inLineRectFHalfAngle;
    //斜边计算左边需要减去环内的距离
    private float outHypotenuseOffset;
    private float inHypotenuseOffset;
    private int deviceSolidBgColor;

    public FiveButtonView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public FiveButtonView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.FiveButtonView);
        strokeColor = ta.getColor(R.styleable.FiveButtonView_five_button_view_stroke_color, 0);
        strokeWidth = ta.getDimensionPixelSize(R.styleable.FiveButtonView_five_button_view_stroke_width, 1);
        drawable = ta.getDrawable(R.styleable.FiveButtonView_five_button_view_drawable);
        centerText = ta.getString(R.styleable.FiveButtonView_five_button_view_center_text);
        textSize = ta.getDimensionPixelSize(R.styleable.FiveButtonView_five_button_view_center_text_size, getResources().getDimensionPixelSize(R.dimen.dp_18));
        textColor = ta.getColorStateList(R.styleable.FiveButtonView_five_button_view_center_text_color);
        // 解析后释放资源
        ta.recycle();
        lineColor = AppApplication.getInstance().getThemeColor(R.attr.secondaryColor8);
        deviceSolidBgColor = AppApplication.getInstance().getThemeColor(R.attr.deviceSolidBgColor);
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setFilterBitmap(true);

        mTextPaint = new TextPaint();
        mTextPaint.setAntiAlias(true);
        mTextPaint.setTextSize(textSize);
        mTextPaint.setTypeface(Typeface.DEFAULT_BOLD);

//        mLineRectF1 = new RectF();
//        mLineRectF2 = new RectF();
//        mLineRectF3 = new RectF();
//        mLineRectF4 = new RectF();
        lineHeight = getResources().getDimensionPixelSize(R.dimen.dp_1);
        centerRadius = getResources().getDimensionPixelSize(R.dimen.dp_30);
        bigStrokeWidth = getResources().getDimensionPixelSize(R.dimen.dp_40);
        shadowRadius1 = getResources().getDimensionPixelSize(R.dimen.dp_52);
        shadowRadius2 = getResources().getDimensionPixelSize(R.dimen.dp_26);
        shadowRadius3 = getResources().getDimensionPixelSize(R.dimen.dp_13);
        shadowRadiusDy1 = getResources().getDimensionPixelSize(R.dimen.dp_26);
        shadowRadiusDy2 = getResources().getDimensionPixelSize(R.dimen.dp_11);
        shadowRadiusDy3 = getResources().getDimensionPixelSize(R.dimen.dp_4);
        addWidth = shadowRadius1 - strokeWidth;
        addWidth = addWidth < 0 ? 0 : addWidth;
        mPath1 = new Path();
        mPath2 = new Path();
        mPath3 = new Path();
        mPath4 = new Path();
        mPath5 = new Path();
        mRingOutRectF = new RectF();
        mRingInRectF = new RectF();
        outLineRectFHalfAngle = (float) (Math.asin(lineHeight / 2f / (bigStrokeWidth + centerRadius + strokeWidth)) / Math.PI * 180);
        inLineRectFHalfAngle = (float) (Math.asin(lineHeight / 2f / (centerRadius + strokeWidth)) / Math.PI * 180);
        inHypotenuseOffset = (float) (lineHeight / 2f / Math.tan(inLineRectFHalfAngle * Math.PI / 180));
        outHypotenuseOffset = (float) (lineHeight / 2f / Math.tan(outLineRectFHalfAngle * Math.PI / 180));
    }

    public void setTextSize(int textSize) {
        this.textSize = textSize;
        mTextPaint.setTextSize(textSize);
        invalidate();
    }

    public void setTextColor(int resId) {
        this.textColor = getResources().getColorStateList(resId);
        invalidate();
    }

    public void setStrokeWidth(int strokeWidth) {
        this.strokeWidth = strokeWidth;
        paint.setStrokeWidth(strokeWidth);
        invalidate();
    }

    float topSectorLeftTopX;
    float topSectorLeftTopY;
    float topSectorLeftBottomX;
    float topSectorLeftBottomY;
    float topSectorRightTopX;
    float topSectorRightTopY;
    float topSectorRightBottomX;
    float topSectorRightBottomY;

    float bottomSectorLeftTopX;
    float bottomSectorLeftTopY;
    float bottomSectorLeftBottomX;
    float bottomSectorLeftBottomY;
    float bottomSectorRightTopX;
    float bottomSectorRightTopY;
    float bottomSectorRightBottomX;
    float bottomSectorRightBottomY;

    //左边扇形4个点
    float leftSectorTopLeftX;
    float leftSectorTopLeftY;
    float leftSectorTopRightX;
    float leftSectorTopRightY;
    float leftSectorBottomLeftX;
    float leftSectorBottomLeftY;
    float leftSectorBottomRightX;
    float leftSectorBottomRightY;

    //右边扇形4个点
    float rightSectorTopLeftX;
    float rightSectorTopLeftY;
    float rightSectorTopRightX;
    float rightSectorTopRightY;
    float rightSectorBottomLeftX;
    float rightSectorBottomLeftY;
    float rightSectorBottomRightX;
    float rightSectorBottomRightY;

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int width = getMeasuredWidth();
        int height = getMeasuredHeight();
        if (addWidth > 0) {
            width = width + addWidth * 2;
            height = height + addWidth * 2;
            setMeasuredDimension(width, height);
        }
        float edgeWidth = addWidth + strokeWidth;
//        mLineRectF1.left = edgeWidth;
//        mLineRectF1.top = (height - lineHeight) / 2f;
//        mLineRectF1.right = mLineRectF1.left + bigStrokeWidth;
//        mLineRectF1.bottom = mLineRectF1.top + lineHeight;
//
//        mLineRectF2.left = (width - lineHeight) / 2f;
//        mLineRectF2.top = edgeWidth;
//        mLineRectF2.right = mLineRectF2.left + lineHeight;
//        mLineRectF2.bottom = mLineRectF2.top + bigStrokeWidth;
//
//        mLineRectF3.right = width - edgeWidth;
//        mLineRectF3.left = mLineRectF3.right - bigStrokeWidth;
//        mLineRectF3.top = (height - lineHeight) / 2f;
//        mLineRectF3.bottom = mLineRectF3.top + lineHeight;
//
//        mLineRectF4.left = (width - lineHeight) / 2f;
//        mLineRectF4.right = mLineRectF2.left + lineHeight;
//        mLineRectF4.bottom = height - edgeWidth;
//        mLineRectF4.top = mLineRectF4.bottom - bigStrokeWidth;

        //45°角邻边
        double adjacentSide = width / 2f - (lineHeight / 2f / Math.sin(Math.PI / 180 * 45f));
        //cos45 = radius / bigC
        float totalC = (float) (adjacentSide / Math.cos(Math.PI / 180 * 45f));
        bigC = totalC - (inHypotenuseOffset - lineHeight / 2f);
        c = totalC - (outHypotenuseOffset - lineHeight / 2f);
        //上扇形4个点
        topSectorLeftTopX = (float) ((c * Math.sin(Math.PI / 180 * 45f)) + (lineHeight / 2f / Math.sin(Math.PI / 180 * 45f)));
        topSectorLeftTopY = (float) (c * Math.cos(Math.PI / 180 * 45f));
        topSectorLeftBottomX = (float) ((bigC * Math.sin(Math.PI / 180 * 45f)) + (lineHeight / 2f / Math.sin(Math.PI / 180 * 45f)));
        topSectorLeftBottomY = (float) (bigC * Math.cos(Math.PI / 180 * 45f));
        topSectorRightTopX = width - topSectorLeftTopX;
        topSectorRightTopY = topSectorLeftTopY;
        topSectorRightBottomX = width - topSectorLeftBottomX;
        topSectorRightBottomY = topSectorLeftBottomY;

        //下扇形4个点
        bottomSectorLeftTopX = topSectorLeftBottomX;
        bottomSectorLeftTopY = height - topSectorLeftBottomY;
        bottomSectorLeftBottomX = topSectorLeftTopX;
        bottomSectorLeftBottomY = height - topSectorLeftTopY;
        bottomSectorRightTopX = width - bottomSectorLeftTopX;
        bottomSectorRightTopY = bottomSectorLeftTopY;
        bottomSectorRightBottomX = width - bottomSectorLeftBottomX;
        bottomSectorRightBottomY = bottomSectorLeftBottomY;

        //左边扇形4个点
        leftSectorTopLeftX = (float) (c * Math.cos(Math.PI / 180 * 45f));
        leftSectorTopLeftY = (float) ((c * Math.sin(Math.PI / 180 * 45f)) + (lineHeight / 2f / Math.sin(Math.PI / 180 * 45f)));
        leftSectorTopRightX = (float) (bigC * Math.cos(Math.PI / 180 * 45f));
        leftSectorTopRightY = (float) ((bigC * Math.sin(Math.PI / 180 * 45f)) + (lineHeight / 2f / Math.sin(Math.PI / 180 * 45f)));
        leftSectorBottomLeftX = leftSectorTopLeftX;
        leftSectorBottomLeftY = height - leftSectorTopLeftY;
        ;
        leftSectorBottomRightX = leftSectorTopRightX;
        leftSectorBottomRightY = height - leftSectorTopRightY;

        //右边扇形4个点
        rightSectorTopLeftX = width - leftSectorTopRightX;
        rightSectorTopLeftY = leftSectorTopRightY;
        rightSectorTopRightX = width - leftSectorTopLeftX;
        rightSectorTopRightY = leftSectorTopLeftY;
        rightSectorBottomLeftX = width - leftSectorBottomRightX;
        rightSectorBottomLeftY = leftSectorBottomRightY;
        rightSectorBottomRightX = width - leftSectorBottomLeftX;
        rightSectorBottomRightY = leftSectorBottomLeftY;

        mRingOutRectF.left = edgeWidth;
        mRingOutRectF.top = edgeWidth;
        mRingOutRectF.right = width - edgeWidth;
        mRingOutRectF.bottom = height - edgeWidth;

        mRingInRectF.left = mRingOutRectF.left + bigStrokeWidth;
        mRingInRectF.top = mRingOutRectF.top + bigStrokeWidth;
        mRingInRectF.right = mRingOutRectF.right - bigStrokeWidth;
        mRingInRectF.bottom = mRingOutRectF.bottom - bigStrokeWidth;

        mPath1.reset();
        mPath1.moveTo(topSectorLeftTopX, topSectorLeftTopY);
        mPath1.arcTo(mRingOutRectF, 225 + outLineRectFHalfAngle, 90 - outLineRectFHalfAngle * 2);
        mPath1.lineTo(topSectorRightBottomX, topSectorRightBottomY);
        mPath1.arcTo(mRingInRectF, 315 - inLineRectFHalfAngle, -90 + inLineRectFHalfAngle * 2);
        mPath1.lineTo(topSectorLeftTopX, topSectorLeftTopY);
        mPath1.close();

        mPath2.reset();
        mPath2.moveTo(rightSectorTopRightX, rightSectorTopRightY);
        mPath2.arcTo(mRingOutRectF, 315 + outLineRectFHalfAngle, 90 - outLineRectFHalfAngle * 2);
        mPath2.lineTo(rightSectorBottomLeftX, rightSectorBottomLeftY);
        mPath2.arcTo(mRingInRectF, 45 - inLineRectFHalfAngle, -90 + inLineRectFHalfAngle * 2);
        mPath2.lineTo(rightSectorTopRightX, rightSectorTopRightY);
        mPath2.close();

        mPath3.reset();
        mPath3.moveTo(bottomSectorRightBottomX, bottomSectorRightBottomY);
        mPath3.arcTo(mRingOutRectF, 45 + outLineRectFHalfAngle, 90 - outLineRectFHalfAngle * 2);
        mPath3.lineTo(bottomSectorLeftTopX, bottomSectorLeftTopY);
        mPath3.arcTo(mRingInRectF, 135 - inLineRectFHalfAngle, -90 + inLineRectFHalfAngle * 2);
        mPath3.lineTo(bottomSectorRightBottomX, bottomSectorRightBottomY);
        mPath3.close();

        mPath4.reset();
        mPath4.moveTo(leftSectorBottomLeftX, leftSectorBottomLeftY);
        mPath4.arcTo(mRingOutRectF, 135 + outLineRectFHalfAngle, 90 - outLineRectFHalfAngle * 2);
        mPath4.lineTo(leftSectorTopRightX, leftSectorTopRightY);
        mPath4.arcTo(mRingInRectF, 225 - inLineRectFHalfAngle, -90 + inLineRectFHalfAngle * 2);
        mPath4.lineTo(leftSectorBottomLeftX, leftSectorBottomLeftY);
        mPath4.close();

        mPath5.reset();
        mPath5.addCircle(width / 2f, height / 2f, centerRadius, Path.Direction.CW);
        mPath5.close();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        float centerX = getWidth() / 2f;
        float centerY = getHeight() / 2f;
        paint.setColor(strokeColor);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(strokeWidth);
        float r = centerX - addWidth - strokeWidth / 2f;
        //最外圆环
        canvas.drawCircle(centerX, centerY, r, paint);

        paint.setStyle(Paint.Style.FILL);
        paint.setShadowLayer(shadowRadius1, 0, shadowRadiusDy1, 0x0f25334b);
        r = centerX - addWidth - strokeWidth;
        //阴影
        canvas.drawCircle(centerX, centerY, r, paint);
        paint.setShadowLayer(shadowRadius2, 0, shadowRadiusDy2, 0x1425334b);
        //阴影
        canvas.drawCircle(centerX, centerY, r, paint);
        paint.setShadowLayer(shadowRadius3, 0, shadowRadiusDy3, 0x0525334b);
        //阴影
        canvas.drawCircle(centerX, centerY, r, paint);
        paint.clearShadowLayer();

        drawCenterBtn(canvas);
        drawOutBtn(canvas);

//        画点来测试扇形4个点算的准不准
//        paint.setColor(AppApplication.getInstance().getThemeColor(R.attr.secondaryColor1));
//        paint.setStrokeWidth(2);
//        paint.setStyle(Paint.Style.FILL);
//        canvas.drawPoint(topSectorLeftTopX, topSectorLeftTopY, paint);
//        canvas.drawPoint(topSectorLeftBottomX, topSectorLeftBottomY, paint);
//        canvas.drawPoint(topSectorRightTopX, topSectorRightTopY, paint);
//        canvas.drawPoint(topSectorRightBottomX, topSectorRightBottomY, paint);
//        canvas.drawPoint(bottomSectorLeftTopX, bottomSectorLeftTopY, paint);
//        canvas.drawPoint(bottomSectorLeftBottomX, bottomSectorLeftBottomY, paint);
//        canvas.drawPoint(bottomSectorRightTopX, bottomSectorRightTopY, paint);
//        canvas.drawPoint(bottomSectorRightBottomX, bottomSectorRightBottomY, paint);
//
//        canvas.drawPoint(leftSectorTopLeftX, leftSectorTopLeftY, paint);
//        canvas.drawPoint(leftSectorTopRightX, leftSectorTopRightY, paint);
//        canvas.drawPoint(leftSectorBottomLeftX, leftSectorBottomLeftY, paint);
//        canvas.drawPoint(leftSectorBottomRightX, leftSectorBottomRightY, paint);
//        canvas.drawPoint(rightSectorTopLeftX, rightSectorTopLeftY, paint);
//        canvas.drawPoint(rightSectorTopRightX, rightSectorTopRightY, paint);
//        canvas.drawPoint(rightSectorBottomLeftX, rightSectorBottomLeftY, paint);
//        canvas.drawPoint(rightSectorBottomRightX, rightSectorBottomRightY, paint);
    }

    private void drawCenterBtn(Canvas canvas) {
        float centerX = getWidth() / 2f;
        float centerY = getHeight() / 2f;
        paint.setStyle(Paint.Style.FILL);
        paint.setColor(deviceSolidBgColor);
        paint.setShadowLayer(shadowRadius1, 0, shadowRadiusDy1, 0x0f25334b);
        canvas.drawCircle(centerX, centerY, centerRadius, paint);

        paint.setShadowLayer(shadowRadius2, 0, shadowRadiusDy2, 0x1425334b);
        canvas.drawCircle(centerX, centerY, centerRadius, paint);

        paint.setShadowLayer(shadowRadius3, 0, shadowRadiusDy3, 0x0525334b);
        canvas.drawCircle(centerX, centerY, centerRadius, paint);
        paint.clearShadowLayer();
        if (isEnabled()) {
            mTextPaint.setAlpha(255);
        } else {
            mTextPaint.setAlpha(80);
        }
        if(getPressKeyPosition() == 5){
            paint.setColor(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
            paint.setStyle(Paint.Style.FILL);
            canvas.drawPath(mPath5, paint);
            mTextPaint.setColor(deviceSolidBgColor);
        }else {
            mTextPaint.setColor(textColor.getColorForState(isSelected() ? SELECTED_STATE_SET : UNSELECTED_STATE_SET, textColor.getDefaultColor()));
        }
        Paint.FontMetricsInt fontMetricsInt = mTextPaint.getFontMetricsInt();
        float textHeight = fontMetricsInt.descent - fontMetricsInt.ascent;
        if (!TextUtils.isEmpty(centerText)) {
            float textWidth = mTextPaint.measureText(centerText);
            String info = centerText;
            info = TextUtils.ellipsize(centerText, mTextPaint, centerRadius * 2, TextUtils.TruncateAt.END).toString();
            textWidth = mTextPaint.measureText(info);
            canvas.drawText(info, (getWidth() - textWidth) / 2f, getHeight() / 2f + textHeight / 2f - fontMetricsInt.descent, mTextPaint);
        }
    }

    private void drawOutBtn(Canvas canvas) {
        float centerX = getWidth() / 2f;
        float centerY = getHeight() / 2f;
        float r = centerX - shadowRadius1 - bigStrokeWidth / 2f;
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(bigStrokeWidth);
        paint.setColor(lineColor);
        //画背景圆环
        canvas.drawCircle(centerX, centerY, r, paint);
        drawable.setBounds((int) (centerX - drawable.getIntrinsicWidth() / 2f),
                (int) (shadowRadius1 + (bigStrokeWidth - drawable.getIntrinsicWidth()) / 2f),
                (int) (centerX + drawable.getIntrinsicWidth() / 2f),
                (int) (shadowRadius1 + (bigStrokeWidth + drawable.getIntrinsicWidth()) / 2f));
        paint.setColor(deviceSolidBgColor);
        paint.setStyle(Paint.Style.FILL);
        canvas.drawPath(mPath1, paint);
        canvas.drawPath(mPath2, paint);
        canvas.drawPath(mPath3, paint);
        canvas.drawPath(mPath4, paint);

        drawPressEffect(canvas);

        if(getPressKeyPosition() == 1){
            drawable.setColorFilter(0xffffffff, PorterDuff.Mode.SRC_ATOP);
        }else{
            drawable.clearColorFilter();
        }
        drawable.draw(canvas);
        canvas.save();
        for (int i = 0; i < 3; i++) {
            if(getPressKeyPosition() == i + 2){
                drawable.setColorFilter(0xffffffff, PorterDuff.Mode.SRC_ATOP);
            }else{
                drawable.clearColorFilter();
            }
            canvas.rotate(90, centerX, centerY);
            drawable.draw(canvas);
        }
        canvas.restore();

//        canvas.save();
//        canvas.rotate(45, centerX, centerY);
//        paint.setColor(lineColor);
//        paint.setStyle(Paint.Style.FILL);
//        canvas.drawRect(mLineRectF1, paint);
//        canvas.drawRect(mLineRectF2, paint);
//        canvas.drawRect(mLineRectF3, paint);
//        canvas.drawRect(mLineRectF4, paint);
//        canvas.restore();
    }

    private void drawPressEffect(Canvas canvas){
        switch (getPressKeyPosition()) {
            case 1:
                paint.setColor(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
                paint.setStyle(Paint.Style.FILL);
                canvas.drawPath(mPath1, paint);
                break;
            case 2:
                paint.setColor(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
                paint.setStyle(Paint.Style.FILL);
                canvas.drawPath(mPath2, paint);
                break;
            case 3:
                paint.setColor(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
                paint.setStyle(Paint.Style.FILL);
                canvas.drawPath(mPath3, paint);
                break;
            case 4:
                paint.setColor(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
                paint.setStyle(Paint.Style.FILL);
                canvas.drawPath(mPath4, paint);
                break;
        }
    }

    @Override
    public void setSelected(boolean selected) {
        super.setSelected(selected);
        invalidate();
    }

    @Override
    public void setEnabled(boolean enabled) {
        super.setEnabled(enabled);
        invalidate();
    }

    @Override
    public int clickPosition(int x, int y) {
        RectF bounds = new RectF();
        Region region = new Region();
        Region clickRegion = new Region();
        mPath1.computeBounds(bounds, true);
        region.set((int) bounds.left, (int) bounds.top, (int) bounds.right, (int) bounds.bottom);
        clickRegion.setPath(mPath1, region);
        if (clickRegion.contains(x, y)) {
            return 1;
        }
        mPath2.computeBounds(bounds, true);
        region.set((int) bounds.left, (int) bounds.top, (int) bounds.right, (int) bounds.bottom);
        clickRegion.setPath(mPath2, region);
        if (clickRegion.contains(x, y)) {
            return 2;
        }
        mPath3.computeBounds(bounds, true);
        region.set((int) bounds.left, (int) bounds.top, (int) bounds.right, (int) bounds.bottom);
        clickRegion.setPath(mPath3, region);
        if (clickRegion.contains(x, y)) {
            return 3;
        }
        mPath4.computeBounds(bounds, true);
        region.set((int) bounds.left, (int) bounds.top, (int) bounds.right, (int) bounds.bottom);
        clickRegion.setPath(mPath4, region);
        if (clickRegion.contains(x, y)) {
            return 4;
        }
        mPath5.computeBounds(bounds, true);
        region.set((int) bounds.left, (int) bounds.top, (int) bounds.right, (int) bounds.bottom);
        clickRegion.setPath(mPath5, region);
        if (clickRegion.contains(x, y)) {
            return 5;
        }
        return 0;
    }
}
